import * as echarts from 'echarts'
const Line2Option = ({ xAxistime, seriesdata, dataColor }) => {
  let options = {
    tooltip: {
      trigger: 'axis',
      axisPointer: {
        type: 'cross',
        label: {
          backgroundColor: '#6a7985',
        },
      },
    },
    grid: {
      top: 30,
      left: 20,
      right: '20',
      bottom: '10%',
      containLabel: true,
    },
    xAxis: [
      {
        type: 'category',
        boundaryGap: false,
        data: xAxistime,
        axisTick: false,
        axisLine: {
          //y轴
          show: false,
          lineStyle: {
            color: '#8D93A7',
            width: 0.5, //线宽
            type: 'dotted',
          },
        },
        axisLabel: {
          //纵坐标的字体样式
          textStyle: {
            color: '#8D93A7',
          },
        },
      },
    ],
    yAxis: [
      {
        type: 'value',
        axisLabel: {
          color: '#8D93A7', //坐标轴的文本颜色
        },
      },
    ],
    dataZoom: [
      {
        type: 'inside',
        start: 1,
        end: 20,
      },
      {
        start: 1,
        end: 12,
        show: false,
      },
    ],
    series: seriesdata.map((item, index) => {
      return {
        name: item.name,
        data: item.data,
        type: 'line',
        showSymbol: false,
        areaStyle: {
          opacity: 0.8,
          color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
            {
              offset: 0,
              color: dataColor.length > 0 ? dataColor[index][1] : '#ccc',
            },
            {
              offset: 1,
              color: dataColor.length > 0 ? dataColor[index][2] : '#ccc',
            },
          ]),
        },
        itemStyle: {
          color: dataColor.length > 0 ? dataColor[index][0] : '#ccc',
        },

        lineStyle: {
          width: 2, //线宽
        },
      }
    }),
  }
  return options
}

export { Line2Option }
